/* 1760. 袋子里最少数目的球 */
/**
 * @param {number[]} nums
 * @param {number} maxOperations
 * @return {number}
 */
/* 
    二分
*/

var minimumSize = function (nums, maxOperations) {
	let left = 1,
		right = nums.reduce((prev, next) => prev + next)

	let ans = 0
	while (left <= right) {
		const y = Math.floor((left + right) / 2)
		let ops = 0
		for (const num of nums) {
			ops += Math.floor((num - 1) / y)
		}
		if (ops <= maxOperations) {
			ans = y
			right = y - 1
		} else {
			left = y + 1
		}
	}
	return ans
}
